package logger

import (
	"team-evaluate/global"

	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
)

func InitLogger(writeSyncer zapcore.WriteSyncer) {
	encoder := getEncoder()
	core := zapcore.NewCore(encoder, writeSyncer, zapcore.DebugLevel)
	logger := zap.New(core, zap.AddCaller())
	global.Logger = logger.Sugar()
}

// getEncoder 获取编码器（如何写入日志）
func getEncoder() zapcore.Encoder {
	encoderConfig := zap.NewProductionEncoderConfig()
	encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
	encoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder
	return zapcore.NewConsoleEncoder(encoderConfig)
}
